home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / LL_LAND.ZIP / LL_LAND.NFO < prev    next >
Text File  |  1993-05-12  |  4KB  |  88 lines

  1. [ Lord Logics Landscape ]
  2.  
  3. Ok, quick key list:
  4.  
  5. Right/Left      - Spin landscape
  6. Forward/Back    - Move in current direction either forward or backward
  7. Space           - Move the water level up and down
  8. ESC             - Exit
  9.  
  10. Ok, along with this file should be the following in the .ZIP you received:
  11.               *.INC     - a bunch of ASM include files
  12.            LL_1.INC     - ASM file that ties together all INC files
  13.               *.  H     - a few C include files
  14.         LL_LAND.  C     - a C program demonstrating the use of ll_land
  15.                           as well as the use of the keyboard and palette
  16.                           routines.
  17.         LL_LAND.EXE     - an executable version of LL_LAND
  18.         LL_LAND.NFO     - this great little file
  19.  
  20. The method I used to calculate the x and y co-ordinates of each point as it
  21. is spinning around is quite simple.  We all know the 3d->2d conversion of:
  22.  
  23. y = y1*d/(z1+d) + 100
  24. x = x1*d/(z1+d) + 160
  25.  
  26. Where x,y is the screen position to draw at, x1,y1,z1 are 3d space co-
  27. ordinates, and d is the pixel space from the user to the screen.
  28.  
  29. Before we do this little conversion, however, we must figure out x1,y1, and
  30. z1.  You can do this several ways.  I chose to it the best way I could 
  31. think of.
  32.  
  33. As we know, COS and SIN work best when given an angle and multiplied
  34. by a vector to give a corresponding X and Y component vector.  So, in order
  35. to utilize this fact, we need to assign an angle THETA to each point to
  36. be displayed and a magnitude R.  
  37.  
  38. The magnitude R is the distance from the point in question to the center of
  39. the displayed grid pattern.  This is given by (X^2 + Y^2) ^ 0.5.  The angle
  40. THETA is the angle that R makes with the vertical axis.  ie:
  41.  
  42.                   1  .  .  .  . |
  43.                   R\ .  .  .  . |
  44.                   .  .\ .  .  __| Y
  45.                   .  .  .\ ./T. |
  46.                   .  .  .  .\ . |
  47.                   .  .  .  .  .\|
  48.                 ----------------
  49.                         X
  50.  
  51. For Point #1, R is the magnitude, and T is the angle THETA. In this case, 
  52. THETA is approximately -45degrees.  All angles, by the way, are given in 
  53. degrees.  I find degrees much easier to work with in integer math as you
  54. can divide the circle up 360 times before you need to use floating point.
  55.  
  56. Anyway, once you have figured out the R and T for all display points (in
  57. the program LL_LAND we use a 46x46 display grid, so 46^2 points are 
  58. calculated) you simply do the following to rotate your image:
  59.  
  60. X = R * SIN (THETA + ALPHA)  where ALPHA is the angle to rotate by. Likewise,
  61. Z = R * COS (THETA + ALPHA)
  62. Y = height at given point (value taken from data in FRACTAL.INC)
  63.  
  64. What?  We use Z here?  Well, the way I looked at the axis was X is horiz.,
  65. Y is vertical, and Z is depth.  Since Z is depth, it corresponds to the
  66. Y position if you were looking at it from the top so to speak.  Anyway, Y 
  67. then becomes the height of the mountain.
  68.  
  69. And that is basically how the display system is done.  By setting up SIN look
  70. up tables and all, a great deal of time is saved in the plotting routine.
  71.  
  72. The method used to put up a color was simple.  Basically, whatever height
  73. a point has, that's what color the pixel becomes.  Before ll_land() was
  74. called, the palette was set up to be blue at #1, black at #0, and then
  75. fade from a bright green to a darker green from #2 to #63 I think, and then
  76. fade from a darker green to a bright white from #64 to #128 or so.
  77.  
  78. -=[ Lord Logics ]=-
  79.  
  80. Any questions or comments, please email me at:
  81. ketrenoj@ucs.orst.edu
  82.  
  83. Oh yeah, if you have some good fast triangle code for unchained video modes
  84. in ASM, and you don't mind giving it out, please email me.  I need a good
  85. fast routine.  Thanx.
  86.  
  87.  
  88.